#ifndef __GAF_FOREACH_H__
#define __GAF_FOREACH_H__


namespace GAF
{
	class ForEach;
}
typedef GAF::ForEach			GAF_IForEach;

#include "GAF_Define.h"

namespace GAF
{
	/// 遍历接口
	class _INTERFACE ForEach
	{
	public:
		/// 遍历所有包含的对象
		virtual Pointer		Foreach(bool isFirst) = 0;
		/// 获得所包含对象数量
		virtual UINT		GetCount() = 0;
	};
}

//**** Foreach循环 ****
/// 遍历循环宏
#define FOREACH(_TYPE, _pArg, _InClass) \
	_TYPE* _pArg = NULL; \
	bool isForeach_##_pArg##_InClass = false; \
	while(NULL != (_pArg = (_TYPE*)_InClass.Foreach(!isForeach_##_pArg##_InClass++)))

/// 遍历循环宏
#define FOREACH_P(_TYPE, _pArg, _pInClass) \
	_TYPE* _pArg = NULL; \
	bool isForeach_##_pArg##_pInClass = false; \
	while(NULL != (_pArg = (_TYPE*)_pInClass->Foreach(!isForeach_##_pArg##_pInClass++)))

// false++ = true , true++ = true , 取反后可以用来标记是非为Foreach的第一次取值

#endif
